﻿#ifndef FRIENDBUTTON_H
#define FRIENDBUTTON_H

#include <QToolButton>
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include "fixedvalue.h"
#include "chatwidget.h"
class FriendButton : public QObject
{
     Q_OBJECT
public:
    explicit FriendButton(unsigned int t_id = 0,QString t_icon = "",QString t_uname = "",QString t_cname = "",QObject *parent = nullptr);
    QToolButton* getButton() const{ return toolButton; }    //获取当前按钮
    void newMessage(QString message);   //有新消息
    QNetworkAccessManager* m_networkManager;
    ChatWidget* getChatWidget()
    {
        return chatwidget;
    }
    int getFriendId()
    {
        return id;
    }

    bool ChatWidgetIsNull()
    {
        if (NULL == chatwidget)
        {
            return true;
        }
        return false;
    }
    void createChatWidget(ChatSocket*ct, int uid,QString uname);

private:
    QToolButton* toolButton;    //用于显示好友昵称等信息
    unsigned int id;    //好友id
    QString icon;   //头像
    QString user_name;   //用户名
    QString comment_name;    //备注名
    ChatWidget* chatwidget;
public slots:
    void slotReplyFinished(QNetworkReply *);
};

#endif // FRIENDBUTTON_H
